<%@ page import="com.example.demo.bean.Student" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/5/31 0031
  Time: 22:06
  To change this template use File | Settings | File Templates.
    主界面
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/main.css">
</head>
<body>
<%--登陆控制，以及添加结果显示--%>
<%
    Cookie[] cookies = request.getCookies();
    String user = "";
    //        不经过登陆直接访问main.jsp,跳转登陆界面
    for (Cookie c : cookies) {
        if(c.getName().equals("user")) {
            if(c.getValue() == null) {
                response.sendRedirect("login.jsp");
            }else {
                user = c.getValue();
            }
        }else if(c.getName().equals("res")) {
            if(c.getValue().equals("1")) {
%>
            <script>alert("添加成功！");</script>
<%
            }else {

            }
        }
    }
%>

<div class="outer">
<%--    顶部介绍栏--%>
    <div class="head">
        <span id="head_text">学生信息管理系统<i class="bi bi-person-circle"></i></span>
        <div class="dropdown" id="dropdown">
            <button id="dropdown_btn" class="btn btn-primary" data-toggle="dropdown" ><span id="dropdown_btn_left"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" class="bi bi-person-circle" viewBox="0 0 16 16">
                    <path d="M11 6a3 3 0 1 1-6 0 3 3 0 0 1 6 0z"/>
                    <path fill-rule="evenodd" d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8zm8-7a7 7 0 0 0-5.468 11.37C3.242 11.226 4.805 10 8 10s4.757 1.225 5.468 2.37A7 7 0 0 0 8 1z"/>
                  </svg></span> <span id="dropdown_btn_mid"><%=user%></span><span class="caret" id="dropdown_btn_right"></span></button>
<%--            账户当前可用功能--%>
            <ul class="dropdown-menu">
                <li><a href="#">修改密码</a></li>
                <li><a href="#">增加管理员</a></li>
                <li><a href="login-admin?status=login-out">退出登陆</a></li>
            </ul>
        </div>
    </div>
<%--    左侧主功能菜单--%>
    <div id="menu_main">
        <div class="dropdown1">
            <button id="dropdown_btn1" class="btn btn-primary"><span id="dropdown_btn_mid1">功能列表</span><span class="caret" id="dropdown_btn_right1"></span></button>
            <ul class="dropdown-menu" id="dd_menu">
                <li id="menu_opt2"><a href="#">学生信息管理</a></li>
                <li id="menu_opt3"><a href="#"></a></li>
                <li id="menu_opt4"><a href="#"></a></li>
                <li id="menu_opt5"><a href="#"></a></li>
            </ul>
        </div>
    </div>
<%--    数据显示 及 增删改查 操作--%>
    <div id="view_main">
        <div id="view_main_ch">
            <div id="view_btn">
                <button id="btn_add" class="btn btn-primary">新增</button>
                <button id="btn_del" class="btn btn-danger">删除</button>
                <button id="btn_set" class="btn btn-primary">修改</button>
                <button id="btn_refresh" class="btn btn-info">重置</button>
                <div id="div_form">
                    <form class="form-inline" action="m-servlet?type=que" method="post">
                        <div class="form-group">
                            <input type="text" class="form-control" placeholder="按学号查询" id="que_sid" name="queSid">
                        </div>
                        <div class="form-group">
                            <input type="text" class="form-control" placeholder="按姓名查询" id="que_sname" name="queSname">
                        </div>
                        <div class="form-group">
                            <button class="btn btn-primary" id="btn_que">查询</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
<%--        数据列表--%>
        <div id="view_table">
            <table class="table table-resposive" id="table">
                <thead>
                <tr>
                    <th></th>
                    <th>学号</th>
                    <th>姓名</th>
                    <th>性别</th>
                    <th>出生日期</th>
                    <th>邮箱</th>
                    <th>备注</th>
                </tr>
                </thead>
<%--                显示从服务器获取的学生信息--%>
                <%
                    List<Student> students = (List<Student>)request.getAttribute("students");
                    for (Student s : students) {
                %>
                <tr>
                    <td><input type="checkbox" name="box"></td>
                    <td><%=s.getSid()%></td>
                    <td><%=s.getSname()%></td>
                    <td><%=s.getGender()%></td>
                    <td><%=s.getBirthday()%></td>
                    <td><%=s.getEmail()%></td>
                    <td><%=s.getImp()%></td>
                </tr>
                <%
                    }
                %>
                <tbody id="tbody">
                </tbody>
            </table>
            <!-- 模态框（Modal） -->
            <div class="modal " id="myModal" role="dialog">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button class="close" data-dismiss="modal" aria-hidden="true">
                                <span>&times;</span>
                            </button>
                            <h4 class="modal-title" id="myModalLabel">
                                新增用户
                            </h4>
                        </div>
                        <div class="modal-body" id="modal-body">
                            <form action="m-servlet" method="post" id="addForm">
                            <label>学号:</label>
                            <input type="text" class="form-control" id="m_sid" placeholder="请输入学号" name="formSid">
                            <label>姓名:</label>
                            <input type="text" class="form-control" id="m_sname" placeholder="请输入姓名" name="formName">
                            <label>性别:</label>
                            <input type="text" class="form-control" id="m_gender" placeholder="请输入性别" name="formGender">
                            <label >出生日期:</label>
                            <input type="text" class="form-control" id="m_birthday" placeholder="请输入出生日期,例：1991-1-1" name="formBirthday">
                            <label >邮箱:</label>
                            <input type="text" class="form-control" id="m_email" placeholder="请输入邮箱" name="formEmail">
                            <label >备注:</label>
                            <input type="text" class="form-control" id="m_imp" placeholder="请输入备注" name="formImp">
                            </form>
                        </div>
                        <div class="modal-footer">
                            <button id="save" class="btn btn-default" data-dismiss="modal">取消
                            </button>
                            <button type="button" class="btn btn-primary" id="subBtn">提交更改</button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal -->
            </div>
        </div>
<%--        表底部翻页按钮--%>
        <div id="pag">
            <ul class="pager">
                <li class="previous" id="pre"> <a href="m-servlet?type=pre"> &laquo; </a> </li>
                <li class="active" id="act"> <a href="m-servlet?type=ref">首页</a> </li>
                <li class="next" id="next"> <a href="m-servlet?type=next">&raquo;</a> </li>
            </ul>
        </div>
    </div>
</div>
<script src="js/jquery-3.4.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/main.js"></script>

</body>
</html>
